# -*- coding: utf-8 -*-
__author__ = 'ggcall'
from cPAMIE import PAMIE

# 测试环境：
# win7 64位
# ie9
# python 2.7.2
# pamie 2.0

ie=PAMIE()
ie.navigate("google.com")

# ie9修改文档模式为ie8标准才可以，默认是ie9标准
# 否则会返回错误如下：
# (<type 'exceptions.TypeError'>, TypeError('getElementsByTagName() takes exactly
# 1 argument (2 given)',), <traceback object at 0x02977670>)
# Traceback (most recent call last):
  # File "C:\Python27\lib\site-packages\cPAMIE.py", line 583, in elementFind
    # elements = self.elementsGetList (tag)
  # File "C:\Python27\lib\site-packages\cPAMIE.py", line 779, in elementsGetList
    # elements = self._ie.Document.getElementsByTagName(tag)
# TypeError: getElementsByTagName() takes exactly 1 argument (2 given)
# ** textBoxGet() did not find q
# ** textBoxSet() did not find q-python

# http://blog.darkthread.net/post-2011-03-28-test-ie9-doc-modes.aspx
# 6.在文件模式中，會有一個選項被標為預設值，代表IE依據HTTP Header、<!doctype>、X-UA-Compatible meta所判別的文件模式。例如: 我們可以加入<meta http-equiv=”X-UA-Compatible” content=”IE=8” />，預設值就會變成IE8標準模式囉。

# ie.textBoxSet('q','python')
# ie.buttonClick('btnK') 
html=ie.pageGetText()
fp = open('pamie2.html','w')
fp.write(html.encode('utf-8'))
fp.close()
ie.quit()